Ext.define('PJ.view.unitregistrationmanagement.SignUpFrame', {
    extend:'AM.default.DefaultWindowForm',
    requires: ['PJ.view.unitregistrationmanagement.ChooseUserTree',
               'PJ.view.unitregistrationmanagement.ChooseUserList',//已选列表
                'PJ.view.unitregistrationmanagement.ChooseNoUserList'//未选列表
               ],
    
    modal: true,// 开启不允许点击其他组件
    frame: true,
    notEdit: true,
    isSame: false,
    isEdit: null,

    initComponent: function(){
    	var me = this;
    	me.items= [{
    		xtype: "container",
    		layout: 'column',
            defaults: {
            	labelAlign: 'right',
            	labelWidth: 65,
            	readOnly: true,
            	padding: '0 0 5 0',
            	columnWidth: .5
            },
    		items: [{
    			xtype: 'textfield',
    			fieldLabel: '班级名称',
//    			name: 'className',
    			value:me.className,
            	fieldCls: 'noBorder',
            	columnWidth: 1
    		}, {
    			xtype: 'textfield',
    			fieldLabel: '举办时间',
            	fieldCls: 'noBorder',
            	value:me.beginDate+'至'+me.endDate
//    			name: 'learnTime'
    		}, {
                xtype: 'fieldset',
            	columnWidth: 1,
                height: 600,
    			padding: '0 0 10 0',
                items: [{
            		xtype: "container",
            		layout: 'column',
            		items: [{
            			title: '组织机构树',
            			xtype: 'ChooseUserTree',
                        height: 530,
                    	columnWidth: .21,
                    	classId:me.classId,
            			clickSource:me.clickSource,
                    	sponsorId:me.sponsorId,
            	        collapsible: false
            		},{
            			title: '待选列表',
            			xtype: 'ChooseNoUserList',
                        height: 315,
                    	columnWidth: .79,
            			classId:me.classId,
            			openState:me.openState,
            			signUpState:me.signUpState,
            			auditingState:me.auditingState,
            			clickSource:me.clickSource,
                    	sponsorId:me.sponsorId,
                    	sponsorName:me.sponsorName,
                    	classUserNum:me.classUserNum,
            			publishState:me.publishState
            		},{
            			title: '已选列表',
            			xtype: 'ChooseUserList',
                        height: 215,
                    	columnWidth: .79,
            			classId:me.classId,
            			openState:me.openState,
            			signUpState:me.signUpState,
            			auditingState:me.auditingState,
            			clickSource:me.clickSource,
            			publishState:me.publishState
            		}]
                }]
    		}, {
    			xtype: 'hidden',
    			name: 'classId',
    			value: me.trainingGradeId
    		}]
    	}];
        me.buttons = [{
            text: '关闭',
            scope: this,
            handler: this.close
        }];
        me.callParent(arguments);
    },
    close: function(){
//    	var win1=this;
//    	if(this.clickSource==2){
//    		Ext.Ajax.request({
//                url: 'module/classuser/findClassUserListNoSignUp.json',
//                method: 'GET',
//                params:{
//                	searchClassID:win1.classId,
//                	isNullByNation:1,
//                	clickSource:this.clickSource
//                    },  
//                //async :  true,
//                success: function (response, options) {
//                    classValue=JSON.parse(response.responseText);
//                    
//                    if(classValue.totalCount==0){
//                    	win = Ext.create('PJ.view.unitregistrationmanagement.CloseUserListFrame',{
//                			title: "确认报名人员",
//                			win: win1,
//                			classId:win1.classId,
//                		}).show();
//                    }else{
//                    	Ext.MessageBox.alert('注意','<div style="color: red;text-align:center;">共有'+classValue.totalCount+'人民族信息不完整</div>');
//                    }
//                },
//                failure: function (response, options) {
//                    Ext.MessageBox.alert('失败', '请求超时或网络故障,错误编号：' + response.status);
//                }
//            });
//    	}else{
//    		this.grid.store.load();
//    		this.destroy();
//    	}
    	this.grid.store.load();
		this.destroy();
	},
	closes: function(){
		this.grid.store.load();
		this.destroy();
	},
    listeners: {
		 // window打开后的事件,刷新已选菜单grid
        show: function(){
            var loadMask = new Ext.LoadMask(this, {
                msg: orchid_lang.promptWindowInfo.loadingText
            });
            this.down("ChooseNoUserList").loadMask = loadMask;
            this.down("ChooseUserList").loadMask = loadMask;
//			//刷新未选人员
            var store = this.down("ChooseNoUserList").getStore();
			var newParams = {
                searchClassID:this.classId,
//				searchDepId:$(document.getElementById("selectScope")).find("option:selected")[0].value
				searchDepId:this.sponsorId
            };
            // 4.0强制更改store参数写法
            var params = store.proxy.extraParams;
            Ext.apply(params, newParams);
            // grid加载生效
            store.isLoad = true;
            store.load();
			
			//刷新已选人员
			var store = this.down("ChooseUserList").getStore();
			var newParams = {
                searchClassID:this.classId,
//				searchDepId:$(document.getElementById("selectScope")).find("option:selected")[0].value,
				searchDepId:this.sponsorId,
    			clickSource:this.clickSource,
            };
            // 4.0强制更改store参数写法
            var params = store.proxy.extraParams;
            Ext.apply(params, newParams);
            // grid加载生效
            store.isLoad = true;
            store.load();
        }
    }
});
